package org.jmc.refmanager.web.wicket.model;

import org.apache.wicket.injection.web.InjectorHolder;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.jmc.refmanager.domain.model.Change;
import org.jmc.refmanager.domain.service.ChangeManager;

/**
 * 
 *
 */
public class ChangeModel extends LoadableDetachableModel<Change> {
	private static final long serialVersionUID = 1L;

	@SpringBean(name="taskManager")
	private ChangeManager taskManager;
	
	private Integer changeId;
	
	/**
	 * 
	 */
	public ChangeModel(Change change) {
		super();
		InjectorHolder.getInjector().inject(this);
		this.changeId = change.getId();
	}

	public ChangeModel(Integer changeId) {
		super();
		InjectorHolder.getInjector().inject(this);
		this.changeId = changeId;
	}

	@Override
	protected Change load() {
//		if (this.change == null && this.changeId != null) {
//			this.change = changeManager.findById(changeId);
//		}
		return this.taskManager.findById(this.changeId);
	}
	
}
